package com.kimi.weibo.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.kimi.weibo.R;
import com.kimi.weibo.bean.Task;
import com.kimi.weibo.service.MainService;
import com.kimi.weibo.ui.base.IWeiboActivity;

/**
 * 
 * 项目名称：Myweibo 类名称：LoginActivity 类描述： 创建人：kimi 创建时间：2013-1-15 上午9:44:47
 * 修改人：kimi 修改时间：2013-1-15 上午9:44:47 修改备注：
 * 
 * @version
 * 
 */
public class LoginActivity extends Activity implements IWeiboActivity{

	private Button btnLogin;

	/*
	 * 单击事件监听
	 */
	class LoginBtnOnClickListener implements OnClickListener {

		/*
		 * (non-Javadoc)
		 * 
		 * @see android.view.View.OnClickListener#onClick(android.view.View)
		 * 执行登录,将登录动作压栈.MainService的线程监听任务后调用doTask方法进行任务处理
		 */
		@Override
		public void onClick(View view) {
			// TODO Auto-generated method stub
			Task task = new Task(Task.USER_LOGIN, null);
			MainService.putToTasks(task);
		}

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
//		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.login);
		Intent service = new Intent(this, MainService.class);
		startService(service);
		//把自己放到Activity集合里面
		MainService.putToActivitis(this);
		
		//对登录按钮添加单击事件
		btnLogin = (Button) this.findViewById(R.id.btnLogin);
		btnLogin.setOnClickListener(new LoginBtnOnClickListener());
	}

	/* (non-Javadoc)
	 * @see com.kimi.weibo.ui.base.IWeiboActivity#init()
	 */
	@Override
	public void init() {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.kimi.weibo.ui.base.IWeiboActivity#refresh()
	 */
	@Override
	public void refresh(Object...params) {
		// TODO Auto-generated method stub
		TextView txtResult  = (TextView) this.findViewById(R.id.txt_result);
		txtResult.setText(params[0].toString());
	}
}
